/*
 * Copyright (c) 2011.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.skavookie.expressions

import math.Numeric._

/**
 * Created by IntelliJ IDEA.
 * User: joshua
 * Date: 6/2/11
 * Time: 11:30 AM
 * To change this template use File | Settings | File Templates.
 */

object JavaUtils {
	def byteIsIntegral = ByteIsIntegral
	def byteManifest = Manifest.Byte
	def intIsIntegral = IntIsIntegral
	def intManifest = Manifest.Int
	def longIsIntegral = LongIsIntegral
	def longManifest = Manifest.Long
	def doubleIsFractional = DoubleIsFractional
	def doubleManifest = Manifest.Double
	def floatIsFractional = FloatIsFractional
	def floatManifest = Manifest.Float

	def literal(x: Byte) = LiteralIntegral(x)
	def literal(x: Int) = LiteralIntegral(x)
	def literal(x: Long) = LiteralIntegral(x)
	def literal(x: Double) = LiteralFractional(x)
	def literal(x: Float) = LiteralFractional(x)
	def literal[T <: Object](x: T) = LiteralExpr[T](x)(Manifest.classType(x.getClass))

	def byteGet(key: KeyType) = GetExpr[Byte](key)
	def intGet(key: KeyType) = GetExpr[Int](key)
	def longGet(key: KeyType) = GetExpr[Long](key)
	def doubleGet(key: KeyType) = GetExpr[Double](key)
	def floatGet(key: KeyType) = GetExpr[Float](key)
	def getObject[T <: Object](key: KeyType, clazz: Class[T]) = GetExpr[T](key)(Manifest.classType(clazz))

	def set(key: KeyType, value: Byte) = SetExpr(key, literal(value))
	def set(key: KeyType, value: Int) = SetExpr(key, literal(value))
	def set(key: KeyType, value: Long) = SetExpr(key, literal(value))
	def set(key: KeyType, value: Double) = SetExpr(key, literal(value))
	def set(key: KeyType, value: Float) = SetExpr(key, literal(value))
	def setObject[T <: Object](key: KeyType, value: T) = SetExpr[T](key, literal[T](value))(Manifest.classType(value.getClass))

//	def castToIntegral()
}